package com.matt.domain.comment;

import com.matt.commons.model.Domain;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * 用来扩展其他的需要评论支持的对象
 */

@Entity
@Data
@Table(name = "tb_comments_obj_ext")
@EqualsAndHashCode(callSuper = true)
public class ExtCommentsSupport extends Domain {

    @Column(columnDefinition = "varchar(255) COMMENT '关联资源 id'")
    @OrderBy
    private String resId;

    @Column(columnDefinition = "int default 1 COMMENT '关联资源类型：1. 时光轴'")
    private int resType;

    @Column(columnDefinition = "int default 0 COMMENT '评论数量'")
    private int commentCount;

    @Column(name = "lastPost", columnDefinition = "datetime COMMENT '最后评论时间'")
    private Date lastPost;

    @Column(columnDefinition = "varchar(255) COMMENT '最后评论用户名'")
    private String lastPostName;

    @Column(columnDefinition = "int default 1 COMMENT '最后评论用户类型, 1. 家长； 2. 老师'")
    private int lastPostUserType;

    @Column(columnDefinition = "varchar(255) COMMENT '最后评论用户 id'")
    private String lastPostUserId;

    @Column(columnDefinition = "varchar(255) COMMENT '最后评论的 id'")
    private String lastCommentId;

    @Column(columnDefinition = "varchar(255) COMMENT '最后评论的短内容'")
    private String lastCommentShortContent;

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "extObj")
    @OrderBy("created ASC")
    private List<Comment> comments;
}





